package easy;

/*
1323. 6 和 9 组成的最大数字
解题思路：巧用stringbuffer
 */
public class LeeCode1323 {

  public int maximum69Number (int num) {

    StringBuffer stringBuffer = new StringBuffer(String.valueOf(num));
    for (int i = 0;i<stringBuffer.length();i++){
      if (stringBuffer.charAt(i) == '6'){
        stringBuffer.deleteCharAt(i);
        stringBuffer.insert(i,9);
        break;
      }
    }
    return Integer.parseInt(stringBuffer.toString());

  }

  public static void main(String[] args) {
    System.out.println(new LeeCode1323().maximum69Number(9996));
  }
}
